export function convertCoordToString(location, scale){
  let lat_sign;
  let lat_num;
  if (location.latitude >= 0){
    lat_sign = 'N';
    lat_num = fixedNum(location.latitude, scale);
  } else {
    lat_sign = 'S';
    lat_num = fixedNum(-location.latitude, scale);
  }
  if (location.longitude >= 0) {
    long_sign = 'E';
    long_num = fixedNum(location.longitude, scale);
  } else {
    long_sign = 'W';
    long_num = fixedNum(-location.longitude, scale);
  }
  return lat_num+lat_sign+'-'+long_num+long_sign
}

function fixedNum(num, scale) {
  let temp_num = Math.floor(num*10*scale)/(10*scale);
  return temp_num.toFixed(scale)
}

export function getAddressDisplay(location){
  let address = location.address;
  if (location.city){
    address = location.city+'-'+address;
  } else if (location.province){
    address = location.province+'-'+address;
  } else if (location.country){
    address = location.country+'-'+address;
  }
  return address
}